package thread.example5;

/**
 * 联合线程
 */
public class JoinDemo {
    public static void main(String[] args) throws Exception {
        System.out.println("begin......");
        Join join = new Join();

        for (int i = 0; i < 50; i++) {
            System.out.println("main"+i);
            if (i == 10) {
                join.start();
            } else if (i == 20) {
                join.join();//让其他线程等待自己执行完， 才能执行mian
            }
        }
    }

}


class Join extends Thread {
    @Override
    public void run() {
        for (int i = 0; i < 50; i++) {
            System.out.println("join"+ i);
        }
    }
}